#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../config/environment'
require "spreadsheet/excel"
include Spreadsheet
users=User.find :all

workbook = Excel.new("#{RAILS_ROOT}/public/reports/report_#{Time.now.strftime('%Y-%m-%d')}.xls")
workbook.codepage = 'WINDOWS-936' 
worksheet = workbook.add_worksheet("Report of #{1.day.ago.strftime('%Y-%m-%d')}")

#worksheet.write(0, 0, "#{1.day.ago.strftime('%Y-%m-%d')}")
#
#worksheet.write(1, 0, "Daily Registered users")
#
#worksheet.write(2, 0, "#{user.chinese_name}")
worksheet.write(0, 0, "Customer name")
worksheet.write(0, 1, "Email")
worksheet.write(0, 2, "Service street address")
worksheet.write(0, 3, "City")
worksheet.write(0, 4, "State")
worksheet.write(0, 5, "Zip")
worksheet.write(0, 6, "Home phone")
worksheet.write(0, 7, "Daytime phone")
worksheet.write(0, 8, "Cable Package")
worksheet.write(0, 9, "Num. of TV's")
worksheet.write(0, 10, "Num. dig A/O")
worksheet.write(0, 11, "Num. HD/DVR")
worksheet.write(0, 12, "HD only")
worksheet.write(0, 13, "Installation date")
worksheet.write(0, 14, "Installation time")
worksheet.write(0, 15, "Alternate installation date")
worksheet.write(0, 16, "Alternate installation time")
worksheet.write(0, 17, "Order num")
worksheet.write(0, 18, "Comments")

i =1
users.each do |u|
  worksheet.write(i,0,u.chinese_name)
  worksheet.write(i,1,u.english_name)
  worksheet.write(i,2,u.remaining)
  i += 1
end


workbook.close
